<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    for(let i  = 0; i < 5; i++){
      // let i = 20
      i = 20
      setTimeout(() => {
        console.log(i)
      }, 0);
    }
    // 结果  0 1 2 3 4
    // 加了let i = 20  结果 20 20 20 20 20
    // 加了i = 20  结果 20


    for(var i  = 0; i < 5; i++){
      setTimeout(() => {
        console.log(i)
      }, 0);
    }
    //   5 5 5 5 5

  </script>
</body>
</html>